package com.zwd.cases.demo.gof23.adapter;

/**
 * @Description 定义一个适配器类，实现新接口，同时持有旧接口的引用
 * @Author zhengwd
 * @Date 2023/4/11 23:14
 **/
public class Adapter implements NewInterface {

    private OldInterface oldInterface;

    public Adapter(OldInterface oldInterface) {
        this.oldInterface = oldInterface;
    }

    @Override
    public void newMethod() {
        // 在新接口的方法中调用旧接口的方法
        oldInterface.oldMethod();
    }
}
